package com.codeoss.framework.db.table;

import java.util.List;

import org.springframework.stereotype.Service;

import com.codeoss.framework.context.YunContext;
import com.codeoss.framework.data.metadata.Query;
import com.codeoss.framework.data.metadata.Table;

@Service
public class OracleTableService extends AbstractTableService {
	public String getPageSQL(YunContext yunContext, Table table, List<String> columnList, Query query) {
		int offset=(query.getPage()-1)*query.getLimit()+1;
		StringBuilder sb=new StringBuilder();
		sb.append("select * from (select t.*, rownum as no from ");
		String sql=getSelectSQL(yunContext, table, columnList, query);
		sb.append("(").append(sql).append(")t)");
		sb.append(" where no>=").append(offset).append(" and no<").append(offset+query.getLimit()); 
		return sb.toString();
	}
	
	
}
